public class Test {

    public int Maxarea(int[] arr){
        //最多盛水的容器
        int left=0,right=arr.length-1,ret=0;
        while(left<right){
            int V=Math.min(arr[left],arr[right])*(right-left);
            ret=Math.max(ret,V);
            if(arr[left]<arr[right]){
                left++;
            }else{
                right--;
            }
        }
        return ret;
    }

    public boolean isHappy(int n) {
        //快乐数
        int fast=bitSum(n),slow=n;
        while(fast!=slow){
            fast=bitSum(bitSum(fast));
            slow=bitSum(slow);
        }
        return fast==1;
    }
    private int bitSum(int n){
        int sum=0;
        while(n!=0){
            int ret=n%10;
            sum+=ret*ret;
            n=n/10;
        }
        return sum;
    }


    public static void main1(String[] args) {
        int[] arr={1,8,6,2,5,4,8,3,7};
        Test obj=new Test();
        int ret=obj.Maxarea(arr);
        System.out.println(ret);
    }

    public static void main(String[] args) {
        Test obj=new Test();
        System.out.println(obj.isHappy(19));
    }
}
